function checkUserForm() {
    var userPassword = $("#userPassword").val();
    var userPassword2 = $("#userPassword2").val();
    var error = $("#errorReset").val();
    if (error != null && error != "") {
        alert(error);
    }
        if (userPassword != null && userPassword != undefined && userPassword != "") {
            if(userPassword==userPassword2){
                $('#resetForm').submit();
            }else {
                alert("两次密码不同，请重新输入");
            }

        } else {
            alert("请输入新密码");
        }

}
function nextCheck() {
    var url = $("#nextStep").attr("src");
    var veryCode = $("#veryCode").val();
    if (veryCode != null && veryCode != "" && veryCode != undefined) {
        $.ajax({
            url: url,
            type: "post",
            dataType: "text",
            data: {code: veryCode},
            success: function (data) {
                if (data == "success") {
                    $("#passwordDiv").show();
                    $("#phoneCheck").hide();
                } else {
                    alert("验证码有误");
                }
            }
        })
    } else {
        alert("请输入验证码");
    }
}
function toLogin() {
    var src = $("#toLogin").attr("src");
    location.href = src;
}

var clock = '';
var nums = 30;
var btn;
function getVeryCode(thisBtn) {
    var url = $("#getCode").attr("atl");
    var phone = $("#phone").val();
    if (phone != null && phone != undefined && phone != "") {
        if (isPoneAvailable(phone)) {
            btn = thisBtn;
            btn.disabled = true; //将按钮置为不可点击
            $("#getCode").attr("style", "background-color: #AAAAAA;")
            btn.value = nums + '秒后可重新获取';
            clock = setInterval(doLoop, 1000); //一秒执行一次
            $.ajax({
                url: url,
                type: "post",
                dataType: "text",
                data: {phone: phone},
                success: function (data) {
                    if (data != "success") {
                        alert(data);
                    }
                }
            })
        } else {
            alert("手机号码不符合规则");
        }

    } else {
        alert("请输入手机号码");
    }

}
function doLoop() {
    nums--;
    if (nums > 0) {
        btn.value = nums + '秒后可重新获取';
    } else {
        clearInterval(clock); //清除js定时器
        btn.disabled = false;
        btn.value = '点击发送验证码';
        $("#getCode").attr("style", "background-color: #36A999;")
        nums = 30; //重置时间
    }
}
function isPoneAvailable(str) {
    var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
    if (!myreg.test(str)) {
        return false;
    } else {
        return true;
    }
}